import asyncio

# 定义一个异步生成器
async def async_generator():
    for i in range(5):
        print(f"Yielding {i}")
        await asyncio.sleep(1)  # 模拟异步操作
        yield i

# 使用 async for 循环来迭代异步生成器
async def main():
    async for value in async_generator():
        print(f"Received {value}")

# 运行主函数
asyncio.run(main())
